require "rjb"
#require 'icu4r'
require 'rubygems'
#require 'parseexcel'
#require 'parseexcel/worksheet'
#require 'parseexcel/parser'
#require 'spreadsheet/excel'
require 'net/http'
require 'net/https'
require 'openssl'
#include Spreadsheet

class TestController < ApplicationController
  def submitlinker
    logger.error params
  end
  
  def av
    
    #    streamSock = SocketHelper.getSocket("tao22071","tao22071")
    #    logger.error "-------------登陆-------------"
    #    logger.error streamSock
    #    if streamSock
    #      #name = SocketHelper.getPinYin("李白")
    #      res = SocketHelper.getCR(streamSock,"avh/taopek+",false)
    #      logger.error "================结果=================="
    #      logger.error res
    #    end
    #    streamSock.close if streamSock
    #    @res = res
    
    #    s = Rjb::import("PlaneSocket")
    #    p = s.new(Constants::SERVER_INFO,Constants::SERVER_PORT,Constants::USERNAME,Constants::PASSWORD)
    #    
    #    @res = CommonHelper.getCR(p,'avh/taopek/28mar')
    #    logger.error "========av result==========="
    #    logger.error @res
    #    
    #    p.closeSocket()
    
  end
  
  def fd
    
    s = Rjb::import("PlaneSocket")
    p = s.new(Constants::SERVER_INFO,Constants::SERVER_PORT,Constants::USERNAME,Constants::PASSWORD)
    
    @res = CommonHelper.getCR(p,'avh/taopek/28mar')
    
    @res2 = CommonHelper.getCR(p,'FD1')
    
    p.closeSocket()
    
  end
  
  def linker
    
  end
  
  def getLinker
    begin
      logger.error "------------------getLinker-------------------"
      pageBegin =  params["start"]
      pageEnd =  params["limit"]
      #orders = Order.find(:all,:conditions => ["link_py = ? OR link_man = ?",params[:query],params[:query]],:select=>"id,link_man,link_tel",:limit =>pageBegin+","+pageEnd)
      orders = Order.find(:all,:conditions => ["link_man like ?","%"+params[:query]+"%"],:select=>"id,link_man,link_tel",:limit =>pageBegin+","+pageEnd)
      jsonstr="{totalProperty:"+orders.length.to_s+",root:"+orders.to_json()+"}"
      
      logger.error params
      render :text=>jsonstr, :layout=>false
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
      
    end
  end
  
  def gridsearch
    
  end
  
  def utf8
    logger.error "李白"
    logger.error URI.escape("李白")
    logger.error params[:type]
    logger.error params[:type] == nil
    if params[:type]
      logger.error "FUCK"
    end
    logger.error "-------------------"
    logger.error URI.escape("中国:.")
    logger.error URI.unescape("%E4%B8%AD%E5%9B%BD+")
    logger.error "-------------------"
    #源文
    #    PAT:A  
    #    没有符合条件的运价  
    #    PAT:
    #Linux
    logger.error URI.escape("PAT:A  
    没有符合条件的运价  
    PAT:")
    logger.error URI.unescape("%0APAT%3AA%20%20%0A%3F%3F%EF%BF%BD%EF%BF%BD%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%20%20%0A%1EPAT%3A")

    #Window
    logger.error URI.unescape("%0APAT%3AA%20%20%0A%E6%B2%A1%E6%9C%89%E7%AC%A6%E5%90%88%E6%9D%A1%E4%BB%B6%E7%9A%84%E8%BF%90%E4%BB%B7%20%20%0A%1EPAT%3A")
    logger.error "-------------------"
    logger.error URI.escape("+")
    logger.error URI.unescape("%E5%BC%A0%E6%A5%A0")
    
  end
  
  def asc
    #    require 'iconv' 
    #    test ="中国"
    #    logger.error Iconv.iconv("ASCII","UTF-8",test)
    # convert ruby characters to their ascii code   
    #"中国".toutf16.each_byte { |tb| logger.error tb.chr }
    #"中国".to_xs.each_byte { |tb| logger.error tb.chr }
    #"中国".each_char { |char| logger.error char }
    #    logger.error ?a   
    #    logger.error ?A   
    #    logger.error ?z   
    #    logger.error ?Z   
    #  
    #    # convert ascii code to ruby characters   
    #    logger.error 97.chr   
    #    logger.error 65.chr   
    #    logger.error 122.chr   
    #    logger.error 90.chr  
    require 'iconv' 
    s = "中国" 
    cov = Iconv.new( 'gb2312', 'utf-8') 
    test = cov.iconv(s)
    logger.error test.length
    test.each_char { |tb| logger.error tb }
    #    logger.error getPingYin("中国")
  end
  
  def getPingYin(hanzi_str )
    ustr=hanzi_str   
    if !hanzi_str.kind_of?(UString)   
      ustr=hanzi_str.u   
    end
    pinyin=""  
    ustr.each{|ch|   
      cp=ch.codepoints[0]   
      if isHanzi(cp)   
        pinyin<<@@str_chinese_first_pinyin[cp-@@hanzi_unicode_start]   
      else  
        pinyin<< ch   
      end  
    }   
    pinyin
  end
  
  def reg
    real_name="/"
    r1 = Regexp.new('[\u4e00-\u9fa5]')
    if(real_name =~ r1)
      logger.error "真实姓名请用汉字填写 ! "
      #errors.add(:real_name, "真实姓名请用汉字填写 ! ") 
    else
      logger.error "Fuck"
    end
  end
  
  def testclass
    RightUtil.print
  end
  
  def explorer
    explorerInfo = request.env["HTTP_USER_AGENT"]
    if explorerInfo.index("MSIE")!=nil
      logger.error "IE"
    else
      logger.error "FF"
    end
  end
  
  def addSingleOrder
    
    
  end
  
  
  def export
    headers['Content-Type'] = "application/vnd.ms-excel" 
    headers['Content-Disposition'] = 'attachment; filename="excel-export.xls"'
    headers['Cache-Control'] = ''
    @records = User.find(:all)
  end
  
  def excel
    begin
      require 'parseexcel'
      require 'parseexcel/worksheet'
      require 'parseexcel/parser'
      path = "#{RAILS_ROOT}/public/reports/test.xls"
      workbook = Spreadsheet::ParseExcel.parse(path)
      #Spreadsheet::ParseExcel::SaveParser - Expand of 
      #Spreadsheet::ParseExcel with 
      #Spreadsheet::WriteExcel 
      worksheet = workbook.worksheet(0)
      row = worksheet.row(0)
      #    logger.error row.at(0).to_s('latin1')
      #    logger.error row.at(1).to_s('latin1')
      #    logger.error row.at(2).to_s('latin1')
      #    logger.error row.at(3).to_s('gb2312')
      #    logger.error worksheet.cell(0, 0).value 
      #worksheet.cell(0, 0).value = 123
      
      worksheet.write(0,0,123)
      logger.error worksheet.cell(0, 0).value 
      #row.at(4) = "123456"
      #logger.error row.at(4).to_s('latin1')
      #logger.error row.at(5).to_s('latin1')
      #workbook.close
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
      
    end
  end
  
  def roo
    require 'rubygems'
    require 'roo'
    
    path = "#{RAILS_ROOT}/public/reports/test.xls"
    oo = Excel.new(path)
    oo.default_sheet = oo.sheets.first
    #oo.set_value(0,0,123)
    logger.error oo.cell(1,1)#.to_s('latin1')
    logger.error oo.cell(1,2)#.to_s('latin1')
    logger.error oo.cell(1,3)#.to_s('latin1')
    logger.error oo.cell(1,4).to_s
    
    #    4.upto(12) do |line|
    #      date       = oo.cell(line,'A')
    #      start_time = oo.cell(line,'B')
    #      end_time   = oo.cell(line,'C')
    #      pause      = oo.cell(line,'D')
    #      sum        = (end_time - start_time) - pause
    #      comment    = oo.cell(line,'F')
    #      amount     = sum * HOURLY_RATE
    #      if date
    #        logger.error "#{date}\t#{sum}\t#{amount}\t#{comment}" 
    #      end
    #    end
    
  end
  
  def sexcel
    logger.error "222222222222222222222222222222222"
    begin
      logger.error "1111111111111111111111"
      #!/usr/bin/env ruby 
      #require File.dirname(__FILE__) + '/../config/environment' 
      #D:\\Depot\\Ruby\\VirtualCommunity\\inspirit\\public\\reports
      require 'rubygems'
      require 'parseexcel'
      #require 'parseexcel/worksheet'
      #require 'parseexcel/parser'
      require 'spreadsheet/excel'
      logger.error "AAAAAAAAAAAAAAAAAAAAAAAAAAA"
      include Spreadsheet
      logger.error "BBBBBBBBBBBBBBBBBBBBBBBBBBB"
      path = "#{RAILS_ROOT}/public/reports/test.xls"
      workbook = Excel.new(path)
      
      worksheet = workbook.add_worksheet
      
      worksheet.write(0, 0, "Hello")
      #worksheet.write(1, 0, ["Matz","Larry","Guido"])
      
      workbook.close
      #logger.error "VERSION: " + Excel::VERSION
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
      
    end
  end
  
  def test
    path = "#{RAILS_ROOT}/public/reports/test.xls"
    workbook = Excel.new(path)
    worksheet = workbook.add_worksheet
    #ic = Iconv.new( 'UTF-8','ISO-8859-1')
    #ic = Iconv.new( 'latin1','ISO-8859-1')
    #ic = Iconv.new( 'UTF-8','GBK')
    # ic = Iconv.new( 'GBK','latin1')
    ic = Iconv.new('latin1','utf-8')
    #ic = Iconv.new('UTF-8','ISO-8859-1')
    logger.error Iconv.iconv("UTF-8//IGNORE","ISO-8859-1//IGNORE","中国")  
    
    #ic = Iconv.new('ISO-8859-15','UTF-8')
    worksheet.write(5, 5, "Hello111111111中国")
    #worksheet.write(1, 0, ["Matz","Larry","Guido"])
    #ic = Iconv.new('ISO-8859-1', 'UTF-8')
    #ic = Iconv.new('latin1','utf-8')
    logger.error ic.iconv("GB2312中国")
    #worksheet.write(0, 0, "#{ic.iconv("仿宋_GB2312")}")
    worksheet.write(1, 0, ["Matz", "Guido", "Larry"])
    
    #pdf.AddGBFont("仿宋",ic.iconv("仿宋_GB2312"))
    workbook.close
  end
  
  def javaexcel
    excel = Rjb::import("JavaExcel").new()
    #excel.importExcel("D:\\Depot\\Java\\Excel\\src\\test.xls");
    excel.importExcel("D:\\Depot\\Ruby\\VirtualCommunity\\inspirit\\public\\reports\\test.xls");
    xcel.excelRead(0,0,0,"String")
    excel.excelWrite(0,0,0,"中国青岛操印度B","String")
    excel.exportExcel("#{RAILS_ROOT}/public/test1.xls");
    redirect_to("#{request.relative_url_root}/reports/test1.xls")
  end
  
  def accform6
    logger.error params
  end
  
  def fortest
    4.upto(12) do |line|
      logger.error line
    end
  end
  
  def teststrr
    a = "[[1,1],[2,2]]".scan(',')
    b = [[1,1]]
    c = "a,b,c,d,e".split(',')
    d = [a]
    logger.error a
  end
  
  def md5
    begin
      require 'digest/md5'
      logger.error Digest::MD5.hexdigest("中国")
      
      #digestUtil = Rjb::import("DigestUtil").new()
      #test = Rjb::import("DigestUtil").hmacSign("HelloWorld","ABC")
      #logger.error test
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
      logger.error "orders md5 :: e="+e.message
    end
  end
  
  def sp
    begin
      require 'digest/md5'
      require 'net/http'
      hmacstr = Digest::MD5.hexdigest("p0_Cmd=Buy&p1_MerId=1070003926&p2_Order=0000001&p3_Amt=0.01&p4_Cur=RMB&p5_Pid=0000001&p6_Url=abc&p7_MP=HelloWord&pa_Details=Agent:1070003926:0;Seller:hellotest0101b:0.01")
      
      Net::HTTP.version_1_2   # 设定对象的运作方式
      Net::HTTP.start('www.yeepay.com', 80) {|http|
        response = http.post('/app-airsupport/AirSupportService.action',
          "p0_Cmd=Buy&p1_MerId=1070003926&p2_Order=0000001&p3_Amt=0.01&p4_Cur=RMB&p5_Pid=0000001&p6_Url=abc&p7_MP=HelloWord&pa_Details=Agent:1070003926:0;Seller:14761779@qq.com:0.01&hmac=#{hmacstr}")
      }
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
      logger.error "orders getOrdersBySearch :: e="+e.message
    end
  end
  
  def yeepay
    
  end
  
  def queryyp
    begin
      require 'digest/md5'
      require 'net/http'
      #hmacstr = Digest::MD5.hexdigest("p0_Cmd=QueryBalance&p1_MerId=1070003926&p2_TargetId=hellotest0101b","")
      #hmacstr = Rjb::import("DigestUtil").hmacSign("p0_Cmd=QueryBalancep1_MerId=1070003926p2_TargetId=hellotest0101b","twes9723.qdticket@yahoo.com.cnqdticket")
      hmacstr = Rjb::import("DigestUtil").hmacSign("QueryBalance1070003926hellotest0101b","twes9723.qdticket@yahoo.com.cnqdticket")
      Net::HTTP.version_1_2   # 设定对象的运作方式
      logger.error "BBBBBBBBBBBBBBB"
      logger.error hmacstr
      Net::HTTP.start('www.yeepay.com', 80) {|http|
        response = http.post('/app-airsupport/AirSupportService.action',
          "p0_Cmd=QueryBalance&p1_MerId=1070003926&p2_TargetId=hellotest0101b&hmac=#{hmacstr}")
      }
      #logger.error "p0_Cmd=QueryBalance&p1_MerId=1070003926&p2_TargetId=hellotest0101b&hmac=#{hmacstr}"
      logger.error "AAAAAAAAAAAAA"
      logger.error response.error
      logger.error response.body
      #logger.error response.key?("r2_Blance") 
      #logger.error response.each {|name,value| logger.error "#{name}=#{value}" } 
      #http://www.yeepay.com/app-airsupport/AirSupportService.action?p0_Cmd=QueryBalance&p1_MerId=1070003926&p2_TargetId=hellotest0101b&hmac=0dd35b73e87dd03124cd8870ea69e77f
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
    end
  end
  
  def testget
    begin
      require 'net/http'
      hmacstr = Rjb::import("DigestUtil").hmacSign("QueryBalance1070003926hellotest0101b","twes9723.qdticket@yahoo.com.cnqdticket")
      
      http = Net::HTTP.new('www.yeepay.com', 80)
      resp, data = http.post('/app-airsupport/AirSupportService.action', "p0_Cmd=QueryBalance&p1_MerId=1070003926&p2_TargetId=hellotest0101b&hmac=#{hmacstr}")
      #打印头信息的方法。
      #resp.each {|key, val| logger.error key + ' = ' + val}
      #logger.error resp.body
      i=0
      resp.body.each do |item|
        #logger.error i=i+1
        logger.error item
      end
      #resp.read_body {|str| logger.error str }
      #logger.error resp.key?('r2_Blance')
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
    end
  end
  
  def ypzz
    begin
      require 'net/http'
      p0_Cmd = 'Buy'
      p1_MerId='1070003926'
      p2_Order='0000001'
      p3_Amt='0.01'
      p4_Cur='RMB'
      p5_Pid='0000001'
      p6_Url='http://localhost:3002/test/getresp'
      p7_MP='HelloWord'
      pa_Details='Platform:qdticket@yahoo.com.cn:0;Seller:hellotest0101b:0.01'
      hmacstr = Rjb::import("DigestUtil").hmacSign("#{p0_Cmd}#{p1_MerId}#{p2_Order}#{p3_Amt}#{p4_Cur}#{p5_Pid}#{p6_Url}#{p7_MP}#{pa_Details}","twes9723.qdticket@yahoo.com.cnqdticket")
      http = Net::HTTP.new('www.yeepay.com', 80)
      action = '/app-airsupport/AirSupportService.action'
      params = "p0_Cmd=#{p0_Cmd}&p1_MerId=#{p1_MerId}&p2_Order=#{p2_Order}&p3_Amt=#{p3_Amt}&p4_Cur=#{p4_Cur}&p5_Pid=#{p5_Pid}&p6_Url=#{p6_Url}&p7_MP=#{p7_MP}&pa_Details=#{pa_Details}&hmac=#{hmacstr}"
      resp, data = http.post(action,params)
      resp.body.each do |item|
        #logger.error i=i+1
        logger.error item
      end
      @content = resp.body
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
    end
  end
  
  def getresp
    logger.error params
    
  end
  
  def queryOrderStatus
    begin
      require 'net/http'
      p0_Cmd = 'QueryStatus'
      p1_MerId='1070003926'
      p2_Order='0000001'
      hmacstr = Rjb::import("DigestUtil").hmacSign("#{p0_Cmd}#{p1_MerId}#{p2_Order}","twes9723.qdticket@yahoo.com.cnqdticket")
      
      http = Net::HTTP.new('www.yeepay.com', 80)
      resp, data = http.post('/app-airsupport/AirSupportService.action', "p0_Cmd=#{p0_Cmd}&p1_MerId=#{p1_MerId}&p2_Order=#{p2_Order}&hmac=#{hmacstr}")
      #打印头信息的方法。
      #resp.each {|key, val| logger.error key + ' = ' + val}
      #logger.error resp.body
      i=0
      resp.body.each do |item|
        #logger.error i=i+1
        logger.error item
      end
      #resp.read_body {|str| logger.error str }
      #logger.error resp.key?('r2_Blance')
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
    end
  end
  
  def testcc
    logger.error "测试"
  end
  
  def sms
    logger.error Constants::SMS_URL
    logger.error Constants::SMS_USER_NAME
    logger.error Constants::SMS_PASSWORD
    logger.error Constants::SMS_HAVEYD
    returnedInfos = Rjb::import("JavaSMS").sendSMS(Constants::SMS_URL,Constants::SMS_USER_NAME,Constants::SMS_PASSWORD,"13853225231,13573832956","祝身体健康，事业有成！",Constants::SMS_HAVEYD)
    logger.error returnedInfos
  end
  
  def testgsub 
    test = ",,,,,,," 
    test = test.gsub(/,,/,",")
    logger.error test
  end
  
  def str
    test = "ABC"
    test.each do|item|
      logger.error item
    end
    
    chars = "A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,"
    charsArray = chars.split(",")
    logger.error charsArray.size
  end
  
  def testdate
    dateEnd = "2008-07-19"
    dateTest = dateEnd.to_date
    logger.error dateTest+1
    logger.error Time.now.strftime("%m")  
  end
  
  def xyz
    
  end
  
  def file
    charstr=""
    File.open("D:\\temp\\gb2312.txt", "r") do |file|  
      #file.each_char { |chr| logger.error "EncodingChar.create(:char=>'#{chr}',:encoding=>'')\n" }
      #      charstr=""
      file.each_line { |line| charstr = line }
      #file.each do |chr|
      #          charstr = chr
      #      end
      #      logger.error charstr.length
      #      i=0
      #      0.upto(charstr.length) do |line|
      #        logger.error charstr[line,line+2]
      #end
    end
    #test = charstr
    test ="中国心"
    logger.error test[1,3]
    #test.each_char { |chr| logger.error chr  }
    test.scan(/.{100}/mu) do |ch|   
      logger.error ch   
      logger.error '============='  
    end  
  end
  
  def fileok
    File.open("D:\\temp\\gb2312.txt", "r") do |file|
      teststr =""
      file.each_line { |line| teststr = line }
      0.upto(183) do |i|
        logger.error i.to_s + "\n"
        logger.error  teststr.chars[i*37+1,37] + "\n"
      end
    end
  end
  
  def etermdb
    File.open("D:\\temp\\gb2312_37.txt", "r") do |file|
      i = 0
      cn = ""
      en = ""
      j = 0 #分析的次数
      logger.error "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
      file.each do |line|
        #        logger.error line
        #        logger.error j
        #logger.error i
        if i == 0 #|| j == 182
          #分析,但判断J是不是1,如果不是+1,下一次分析
          if j==0
            j=1 
          else
            0.upto(36) do |k|
              #logger.error "k,k+1:#{k}:#{k+1}"
              #logger.error "k*2,k*2+2:#{k*2}:#{k*2+2}"
              logger.error "#{cn.chars[k,1]}:#{en[k*2,2]}"
              ch_char = cn.chars[k,1]
              en_char = en[k*2,2]
              encodingChar =  EncodingChar.new
              encodingChar.char = ch_char
              encodingChar.encoding = en_char
              encodingChar.save
            end
            j=j+1
          end
        elsif i == 1
          #logger.error "KKKKKKKKKKKKKKKKKKKKK"
          cn = line
        elsif i==2
          en = line
        end
        #为下一次处理作准备
        if i+1 == 3
          if j==183
            #如果J=183在此要单独处理一下.
            0.upto(29) do |k|
              #logger.error "k,k+1:#{k}:#{k+1}"
              #logger.error "k*2,k*2+2:#{k*2}:#{k*2+2}"
              logger.error "#{cn.chars[k,1]}:#{en[k*2,2]}"
              ch_char = cn.chars[k,1]
              en_char = en[k*2,2]
              encodingChar =  EncodingChar.new
              encodingChar.char = ch_char
              encodingChar.encoding = en_char
              encodingChar.save
            end
          end
          i = 0
        else
          i=i+1
        end
        
      end
      #logger.error "---------------------------------------------"
      
    end
  end
  
  def setpinyin
    begin
      javaUtil = Rjb::import("JavaUtil")
      encodingChars = EncodingChar.find(:all)
      0.upto(encodingChars.length-1) do |i|
        encodingChars[i].py = javaUtil.getPinYin(encodingChars[i].char)
        encodingChars[i].save
      end
      logger.error javaUtil.getPinYin("中")
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
      logger.error e
    end
  end
  
  def testRevertCN
    #    logger.error "abcdsdfsdfsfsdfdsfkk"[1,2]
    #    logger.error "abcdsdfsdfsfsdfdsfkk"[3..(20-3)]
    #    logger.error "adfadffafd".index("fa")
    revertCN(0x27.chr+0x14.chr+"afafdssfdsfdasfdsfadsfdsafas"+0x27.chr+0x15.chr+"adfafafasdfadsffsa")
    #revertCN("")
  end
  
  def testsock
    begin
      logger.error "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
      #处理登录时非常长的0,以补位
      loginTailStr = ""
      1.upto(138) do |i|
        loginTailStr = loginTailStr + 0x00.chr    
      end
      inStr = 0x01.chr+0xA2.chr+"user74"+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+"pswd74"+loginTailStr
      #inCStr =0x01.chr+0x00.chr+0x00.chr+0x20.chr+0x00.chr+0x00.chr+0x00.chr+0x01.chr+0x51.chr+0x40.chr+0x70.chr+0x02.chr+0x1B.chr+0x0B.chr+0x20.chr+0x20.chr+0x00.chr+0x0F.chr+0x1E.chr+"avh/taopek+"+0x20.chr+0x03.chr
      commandHeadStr = 0x01.chr+0x00.chr+0x00.chr+0x26.chr+0x00.chr+0x00.chr+0x00.chr+0x01.chr+0x51.chr+0x40.chr+0x70.chr+0x02.chr
      commandSubHeadStr = 0x1B.chr+0x0B.chr+0x20.chr+0x20.chr+0x00.chr+0x0F.chr+0x1E.chr
      commandTailStr = 0x20.chr+0x03.chr
      inCStr = commandHeadStr + commandSubHeadStr +"nm1 liyou"+0x1B.chr+0x0E.chr+0x40.chr+0x6E.chr+0x53.chr+0x50.chr+0x1B.chr+0x0F.chr+commandTailStr
      timeout(1) do
        streamSock = TCPSocket::new( "pfhk.3322.org", 350 )
        logger.error "login.........."
        #返回信息中有10004,说明正在登录的用户名有人正在使用中.
        streamSock.send( inStr ,0)
        responseStr =  streamSock.recv( 128 )
        logger.error "Logon.........."
        logger.error responseStr.each_byte { |byte| logger.error byte.chr }
        #streamSock.send( inCStr ,0)
        #logger.error streamSock.recv( 2048 ).length
        #return re.replace('\r', '\n').replace('>', '\n');
        #responseStr =  streamSock.recv( 2048 )
        responseStr = responseStr.gsub(/\r/, "\n")
        responseStr = responseStr.gsub(/>/, "\n")
        #revertCN(responseStr)
        streamSock.close
      end
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
      
      logger.error "ERROR:"
      logger.error e
    end
  end
  
  def revertCN(originalStr)
    #logger.error originalStr.index((0x1B.chr+0x0E.chr),0)
    begin
      pi = 0 #当前要开始搜索的位置
      i = 0 #顺序,记录第几个中文串
      likeStr = "" #数据库搜索like条件
      cnHash = Hash.new
      arr = []
      while originalStr.index((0x1B.chr+0x0E.chr),pi)
        i = i + 1
        bi = originalStr.index((0x1B.chr+0x0E.chr),pi) #开始位置
        ei = originalStr.index((0x1B.chr+0x0F.chr),pi)+1 #结束位置
        pi = bi #更新当前要开始搜索的位置
        currentCNStr = originalStr[bi..ei] #
        pureCNCodeStr = currentCNStr[2..(currentCNStr.length-3)]
        cnHash[i] = pureCNCodeStr #把纯汉字编码打入Hash
        originalStr = originalStr.gsub("#{currentCNStr}","|#{i}|") #对第i个汉字串进行替换,都替换为|i|的形式
        #同时拼了个下一步准备查数据库的长字串
        0.upto(pureCNCodeStr.length/2-1) do |j|
          value = pureCNCodeStr[j*2,2]
          if arr[0]
            arr[0] << " or encoding=?"
          else
            arr[0] = "encoding=?"
          end
          arr.push(value)
        end
      end
      #如果确实有汉字存在,扫行数据库操作查出所有相关的汉字
      
      if i >0
        cnDBHash = Hash.new
        encodingChars = EncodingChar.find(:all,:conditions=>arr) 
        encodingChars.each do |encodingChar|
          cnDBHash["#{encodingChar.encoding}"] = encodingChar.cn_char
        end 

        #开始替换HASH编码为真正汉字
        1.upto(i) do |k|
          subCNStr = ""
          cnEncodedStr = cnHash[k]
          0.upto(cnEncodedStr.length/2-1) do |l|
            subCNStr << cnDBHash["#{cnEncodedStr[l*2,2]}"]
          end
          cnHash[k]=subCNStr
        end
        
        #开始把HASH中的真正汉字全换入原始串中.
        1.upto(i) do |m|
          originalStr = originalStr.gsub("|#{m}|","#{cnHash[m]}")
        end
        logger.error originalStr
      end
      originalStr
      #以上主要是处理了汉字所在的位置,然后根据位置存储了相应的汉字编码.
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
      
      logger.error "ERROR:"
      logger.error e
    end
  end
  
  def testHEX
    logger.error 10.chr
    logger.error Time.new.to_s
  end
  
  def testpek
    begin
      logger.error "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
      #处理登录时非常长的0,以补位
      loginTailStr = ""
      1.upto(136) do |i|
        loginTailStr = loginTailStr + 0x00.chr    
      end
      loginFirstStr = 0x01.chr+0xA2.chr+"tao22070"+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+"tao22070"+loginTailStr
      loginSecondStr = 0x01.chr+0xFE.chr+0x00.chr+0x11.chr+0x14.chr+0x00.chr+0x00.chr+0x02.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr
      loginThirdStr = 0x01.chr+0xFE.chr+0x00.chr+0x11.chr+0x14.chr+0x10.chr+0x00.chr+0x02.chr+0x0C.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x01.chr+0xFE.chr+0x00.chr+0x11.chr+0x14.chr+0x10.chr+0x00.chr+0x02.chr+0x29.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr+0x00.chr
      loginFourthTailStr=""
      1.upto(61) do |i|
        loginFourthTailStr = loginFourthTailStr + 0x00.chr    
      end
      loginFourthStr = 0x01.chr+0xF9.chr+ 0x00.chr+ 0x44.chr+ 0x00.chr+ 0x01.chr+ 0x0B.chr+loginFourthTailStr 
      
      inCStr =0x01.chr+0x00.chr+0x00.chr+0x20.chr+0x00.chr+0x00.chr+0x00.chr+0x01.chr+0x36.chr+0x51.chr+0x70.chr+0x02.chr+0x1B.chr+0x0B.chr+0x20.chr+0x20.chr+0x00.chr+0x0F.chr+0x1E.chr+"avh/taopek+"+0x20.chr+0x03.chr
      commandHeadStr = 0x01.chr+0x00.chr+0x00.chr+0x26.chr+0x00.chr+0x00.chr+0x00.chr+0x01.chr+0x36.chr+0x51.chr+0x70.chr+0x02.chr
      commandSubHeadStr = 0x1B.chr+0x0B.chr+0x20.chr+0x20.chr+0x00.chr+0x0F.chr+0x1E.chr
      commandTailStr = 0x20.chr+0x03.chr
      #inCStr = commandHeadStr + commandSubHeadStr +"nm1 liyou"+0x1B.chr+0x0E.chr+0x40.chr+0x6E.chr+0x53.chr+0x50.chr+0x1B.chr+0x0F.chr+commandTailStr
      timeout(5) do
        streamSock = TCPSocket::new( "pek4.3322.org", 350 )
        logger.error "login.........."
        #返回信息中有10004,说明正在登录的用户名有人正在使用中.
        streamSock.send( loginFirstStr ,0)
        responseStr =  streamSock.recv( 128 )
        logger.error "Logon.........."
        streamSock.send( loginSecondStr ,0)
        responseStr =  streamSock.recv( 128 )
        logger.error responseStr
        streamSock.send( loginThirdStr ,0)
        responseStr =  streamSock.recv( 256 )
        logger.error responseStr
        #        streamSock.send( loginFourthStr ,0)
        #        responseStr =  streamSock.recv( 256 )
        #        logger.error responseStr
        #logger.error responseStr.each_byte { |byte| logger.error byte.chr }
        responseStr =  streamSock.recv( 512 )
        streamSock.send( inCStr ,0)
        #logger.error streamSock.recv( 2048 ).length
        #return re.replace('\r', '\n').replace('>', '\n');
        responseStr =  streamSock.recv( 2048 )
        responseStr = responseStr.gsub(/\r/, "\n")
        responseStr = responseStr.gsub(/>/, "\n")
        logger.error responseStr
        #revertCN(responseStr)
        streamSock.close
      end
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
      
      logger.error "ERROR:"
      logger.error e
    end
  end
  
  def testp
    begin
      logger.error Rails.public_path
      logger.error Rails.logger
      logger.error RAILS_ENV
      logger.error Rails.version
      CommonHelper.infoLogger(session[:user_id],request.env["REMOTE_ADDR"],params[:controller],params[:action],e,"error")
      #logger.error request.env["REMOTE_ADDR"]

    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
      
      logger.error "ERROR:"
      logger.error e
    end
  end
  
  def testgsub
    logger.error "testtesttest"
    #logger.error "\\"
    #logger.error "\\".gsub('\\',"\\\\")
  end
  
  def amount
    logger.error ErrorInfo.length
  end
  
  def httpc
    begin
      require 'httpclient'
      logger.error ENV['HTTP_PROXY']
      clnt = HTTPClient.new("http://localhost:3000/test/testgsub")
      logger.error ARGV.shift
      target = ARGV.shift# || "http://localhost:3000/foo.cgi"
      #logger.error clnt.get_content(target)
      result = clnt.get("")
      #logger.error result
      logger.error result.header
      logger.error result.body
      logger.error result.content
    rescue Exception => e
      logger.error(":controller=#{params[:controller]},:action=#{params[:action]},:params=#{params},:user_id=#{session[:user_id]}")
      logger.error e
    end    
  end
  
  def httpc1
    require 'httpclient'
    c = HTTPClient.new
    conn = c.get_async("http://localhost:3000/test/testgsub")
    io = conn.pop.content
    while str = io.read(40)
      p str
    end
  end
  
  def httpc2
    url = URI.parse('https://epcis-agent.paic.com.cn/j_security_check?j_username=QDHJSWYXGS-00001&j_password=liutao666')
    #get = Net::HTTP::Get.new(url.path)
    get = Net::HTTP::Get.new("https://epcis-agent.paic.com.cn/j_security_check?j_username=QDHJSWYXGS-00001&j_password=liutao666")
    response = http.request(get)
    logger.error response.body
  end
  
  def http3
    require 'net/http'     
    Net::HTTP.start('https://epcis-agent.paic.com.cn', 80) do |http|     
      response = http.get('/j_security_check?j_username=QDHJSWYXGS-00001&j_password=liutao666')  
      logger.error "Code: #{response.code}"      
      logger.error "Message: #{response.message}"    
      logger.error "Body:\n #{response.body}"    
    end
  end
  
  def https
    require 'net/http'
    require 'net/https'
     
    http = Net::HTTPS.new('epcis-agent.paic.com.cn', 443)
    http.use_ssl = true
    path = '/j_security_check?j_username=QDHJSWYXGS-00001&j_password=liutao666'
    
    # GET request -> so the host can set his cookies
    resp, data = http.get(path, nil)
    cookie = resp.response['set-cookie']
    
    
    #    # POST request -> logging in
    #    data = 'serwis=wp.pl&url=profil.html&tryLogin=1&countTest=1&logowaniessl=1&login_username=blah&login_password=blah'
    #    headers = {
    #      'Cookie' => cookie,
    #      'Referer' => 'http://profil.wp.pl/login.html',
    #      'Content-Type' => 'application/x-www-form-urlencoded'
    #    }
    #  
    #    resp, data = http.post(path, data, headers)
 
    # Output on the screen -> we should get either a 302 redirect (after a successful login) or an error page
    logger.error 'Code = ' + resp.code
    logger.error 'Message = ' + resp.message
    resp.each {|key, val| logger.error key + ' = ' + val}
    logger.error data
  end
  
    
  
  def GoogleLogin(username, password)   
    url = URI.parse('https://www.google.com/accounts/ClientLogin')   
    http = Net::HTTP.new(url.host, url.port)   
    http.use_ssl = true  
    res = http.start do |http|   
      req = Net::HTTP::Post.new(url.path)   
      req.set_form_data({'Email'=>username, 'Passwd'=>password, 'service'=>'xapi', 'source'=>'rails-plugins'},'&')   
      http.request(req)   
    end  
    case res   
    when Net::HTTPSuccess #, Net::HTTPRedirection   
      true  
    else  
      false  
    end  
  end  

  
  def testgoogle
    if GoogleLogin('wangchangxiao@gmail.com','')   
      logger.error "suc"  
    else  
      logger.error "failed"  
    end  
  end
  
  def paLogin(username, password)  
    begin
      epcisCA = "#{Rails.public_path}/epcis_base64.cer"
      #epcisCA = "#{Rails.public_path}/epcis.cer"
      url = URI.parse("https://epcis-agent.paic.com.cn/j_security_check?j_username=QDHJSWYXGS-00001&j_password=liutao666")
      #path = "https://epcis-agent.paic.com.cn/j_security_check?j_username=QDHJSWYXGS-00001&j_password=liutao666"
      logger.error url
      http = Net::HTTP.new(url.host, url.port)   
      http.use_ssl = true  
      #http.enable_post_connection_check = true
      if File.exist? epcisCA
        logger.error epcisCA
        http.ca_file = epcisCA
        #http.verify_mode = OpenSSL::SSL::VERIFY_PEER
        #http.verify_mode = OpenSSL::SSL::OP_NO_SSLv3
        #http.verify_depth = 5
        #warning: peer certificate won't be verified in this SSL session
      else
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      end
      logger.error "------------------------------Login................................-------------"
      logger.error url.path
      logger.error username
      logger.error password
      puts url.host
      puts url.port
      puts url.path
      resp = http.start do |http| 
        http.get('https://epcis-agent.paic.com.cn/j_security_check?j_username=QDHJSWYXGS-00001&j_password=liutao666')
        
        #req = Net::HTTP::Get.new("/j_security_check?j_username=QDHJSWYXGS-00001&j_password=liutao666") 
        #req = Net::HTTP::Get.new(url.path) 
        #req = Net::HTTP::Post.new("/j_security_check")
        #req.set_form_data({'j_username'=>"#{username}", 'j_password'=>"#{password}", 'service'=>'xapi', 'source'=>'rails-plugins'},'&')
        #puts req.body
        #http.request(req)   
      end  
      puts "--------------------------End Get----------------------------------------"
      #resp, data = http.get(path, nil)
      logger.error "-------------------Response First---------------------"
      logger.error resp.code
      logger.error resp.message
      body = resp.body
      posi =  body.index("jsessionid")
      jsession = body[posi,73]
      @html_body = body
      logger.error body
      #      res = http.start do |http|   
      #        #req = Net::HTTP::Get.new(url.path)   
      #        req = Net::HTTP::Get.new(url)  
      #        #req.set_form_data({'j_username'=>username, 'j_password'=>password, 'service'=>'xapi', 'source'=>'rails-plugins'},'&')   
      #        http.request(req)   
      #      end  
    
      #      logger.error res.code
      #      logger.error res.message
      #      logger.error res.body
      #      logger.error res.body
    
      #url = URI.parse('https://epcis-agent.paic.com.cn')
      path = "https://epcis-agent.paic.com.cn/agentApply.do?planCode=250&"+jsession
      #path = "https://epcis-agent.paic.com.cn/plan_select.jsp"+"?"+jsession
      #http = Net::HTTP.new(url.host, url.port)   
      #http.use_ssl = true  
      puts path
      if File.exist? epcisCA
        #logger.error epcisCA
        #http.ca_file = epcisCA
        #http.verify_mode = OpenSSL::SSL::VERIFY_PEER
        #http.verify_mode = OpenSSL::SSL::OP_NO_SSLv3
        #http.verify_depth = 3
      else
        http.verify_mode = OpenSSL::SSL::VERIFY_NONE
      end
      #resp, data = http.get(path, nil)
      logger.error resp.code
      logger.error resp.message
      logger.error resp.body
      puts Iconv.iconv("UTF-8//IGNORE","GB2312//IGNORE",resp.body) 
      #      res = http.start do |http|   
      #        req = Net::HTTP::Get.new(url.path)   
      #        req.set_form_data({'planCode'=>'250', 'service'=>'xapi', 'source'=>'rails-plugins'},'&')   
      #        http.request(req)   
      #      end  
      case resp   
      when Net::HTTPSuccess #, Net::HTTPRedirection   
        true  
      else  
        false  
      end  
      @html_body
    rescue Exception => e
      logger.error e
    end 
  end  
  
  def testpa
    #    if paLogin('QDHJSWYXGS-00001','liutao666')
    #      logger.error "suc"  
    #    else  
    #      logger.error "failed"  
    #    end
    @html_body = paLogin('QDHJSWYXGS-00001','liutao666')
  end
  
  def testlength
    teststr =  "123123123213jsessionid=LlZWh8p5JTMmGNPTGjyqy1gy06kNhZ0dGH82pTwCdnnwhtcXp0kr!969274865-1232123"
    posi =  teststr.index("jsessionid")
    logger.error teststr[posi,73]
  end
  
  def htmlp
    url = URI.parse('https://epcis-agent.paic.com.cn/')
    req = Net::HTTP::Get.new(url.path)
    res = Net::HTTP.start(url.host, url.port) {|http|
      http.request(req)
    }
    puts res.body


  end
  
  def testhc
    begin
      require 'httpclient'
      epcisCA = "#{Rails.public_path}/epcis_base64.cer"
      h = HTTPClient.new()
      #h.ssl_config.set_crl(crl_file)
      h.ssl_config.set_trust_ca(epcisCA)
      url = "https://epcis-agent.paic.com.cn/j_security_check?j_username=QDHJSWYXGS-00001&j_password=liutao666"
      url1 = "https://epcis-agent.paic.com.cn/getAgentInfo.do"
      url2 = "https://epcis-agent.paic.com.cn/agentApply.do?planCode=250"
      url3 = "https://epcis-agent.paic.com.cn/agentPolicyInfoQuery.do?planCode=250&startTime=2008-08-01&endTime=2008-08-16&agentCode=11340065&target=_self&queryFlag=1"
      userName = Iconv.iconv("ISO-8859-1//IGNORE","UTF-8//IGNORE","张百发")
      beneficiaryName = Iconv.iconv("ISO-8859-1//IGNORE","UTF-8//IGNORE","法定")
      userName = "张百强"
      beneficiaryName = "法定"
      javaUtil = Rjb::import("JavaUtil")
      userName = javaUtil.stringEncoder(userName,"GBK")
      beneficiaryName = javaUtil.stringEncoder(beneficiaryName,"GBK")
      #url4 = "https://epcis-agent.paic.com.cn/printPolicy.do?flag=9&insuranceBeginTime=2008-08-16&insuranceEndTime=2008-08-26&applyNum=1&beneficiaryName=法定&planCode=250&certificateNo=370208000000000001&certificateType=01&insuredName=张百发&premium=20.0&insuredAmount=400000.0&printDate=&cancelDate=&queryFlag=0&applyRegisterNo="
      url4 = "https://epcis-agent.paic.com.cn/printPolicy.do?flag=9&insuranceBeginTime=2008-08-16&insuranceEndTime=2008-08-26&applyNum=1&beneficiaryName=#{beneficiaryName}&planCode=250&certificateNo=370208196510200001&certificateType=01&insuredName=#{userName}&premium=20.0&insuredAmount=400000.0&printDate=&cancelDate=&queryFlag=0&applyRegisterNo="
      #agentCode=11340065
      #plan_Code=250
      #startTime=2008-08-01
      #endTime=2008-08-16
      #action=agentPolicyInfoQuery.do
      content = h.get_content(url)
      content1 = h.get_content(url1)
      content2 = h.get_content(url2)
      content3 = h.get_content(url3)
      #content4 = h.get_content(url4)
      #content4 = h.request('POST',"https://epcis-agent.paic.com.cn", {'flag' => '9','planCode'=>'250' ,'insuranceEndTime' => "2008-08-26", 'action' => "/printPolicy",'applyNum'=>'1','beneficiaryName'=>"法定",'ertificateNo'=>"370208000000000002",'insuredName'=>"张百发",'certificateType'=>'01','premium'=>'20.0','&insuredAmount'=>'400000.0','printDate'=>'','cancelDate'=>'','queryFlag'=>'0','applyRegisterNo'=>''})
      content4 = h.post(URI.parse(url4))
      @contentstr = Iconv.iconv("UTF-8//IGNORE","GB2312//IGNORE",content)
      puts "--------------------------Content------------------------------------"
      puts @contentstr
      puts "--------------------------Content1------------------------------------"
      puts Iconv.iconv("UTF-8//IGNORE","GB2312//IGNORE",content1)
      puts "--------------------------Content2------------------------------------"
      #puts Iconv.iconv("UTF-8//IGNORE","GB2312//IGNORE",content2)
      puts "--------------------------Content3------------------------------------"
      #puts Iconv.iconv("UTF-8//IGNORE","GB2312//IGNORE",content3)
      puts "--------------------------Content4------------------------------------"
      puts Iconv.iconv("UTF-8//IGNORE","GB2312//IGNORE",content4.content)
      posi =  content4.content.index("id=\"applyRegisterNo\" value=\"")
      registerNo = content4.content[posi+28,16]
      puts registerNo #保单号
      #id="applyRegisterNo" value="1192500802422956"
    rescue Exception => e
      puts e
    end
  end
  
  def testsubstr
    test="id=\"applyRegisterNo\" value=\"1192500802422956\""
    posi =  test.index("id=\"applyRegisterNo\" value=\"")
    registerNo = test[posi+28,16]
    puts registerNo
    puts Iconv.iconv("ISO-8859-1//IGNORE","GB2312//IGNORE","张百发")
    userName = Iconv.iconv("ISO-8859-1//IGNORE","UTF-8//IGNORE","张百发")
    beneficiaryName = Iconv.iconv("ISO-8859-1//IGNORE","UTF-8//IGNORE","法定")
    puts userName
    puts beneficiaryName
    puts "-------------------------------------------------------"
    puts Iconv.iconv("GB2312//IGNORE","ISO-8859-1//IGNORE",beneficiaryName)
  end
  
  def testpost
    puts "--------------------------Test Post-----------------------"
    logger.error "--------------------------Test Post-----------------------"
  end
  
  def tpost
    puts URI.escape("张百发")
    puts Iconv.iconv("GBK//IGNORE","UTF-8//IGNORE","张百发")
    #https://epcis-agent.paic.com.cn/printPolicy.do?flag=9&insuranceBeginTime=2008-08-16&insuranceEndTime=2008-08-26&applyNum=1&beneficiaryName=%B7%A8%B6%A8&planCode=250&certificateNo=370208000000000001&certificateType=01&insuredName=%D5%C5%B0%D9%B7%A2&premium=20.0&insuredAmount=400000.0&printDate=&cancelDate=&queryFlag=0&applyRegisterNo=
    h = HTTPClient.new()
    require 'iconv'
    # will convert from UTF8 to UTF16
    puts Iconv.new('GBK', 'utf-8').iconv("张百发")
  end
  
  def testr
    begin
      puts session[:user_id]
      TicketController.test
      puts "2231"
    rescue Exception => e
      puts "FUCK"
      puts e
      CommonHelper.infoLogger(session[:user_id],request.env["REMOTE_ADDR"],params[:controller],params[:action],e,"error")
    end
  end
  
  def hz
    puts "中国".chars.length
    puts CommonHelper.formatBirthdayToDate("370206750620129")
    puts CommonHelper.formatBirthdayToDate("370206197606203232")
    puts "ABCDEFG"[3..-1]
    puts "F8 A5 YA KA BA EA HA LA MA".split(" ")[0]
    puts "CA1572 DS# FL AL Y7 BS MS HS KS LS QS GS TAOPEK 0955 1110 733 0^S "[58,3]

    a = ["A","B","C"]
    b="C".split("")
    puts a-b
  end
  
  def rcc
    rCC = Regexp.new('[\u4e00-\u9fa5]')
    puts "12313" =~ rCC
    puts "@!# {"  =~ rCC
    puts "你好" =~ rCC
    puts "ABC" =~ rCC
    puts "A中BC" =~ rCC
  end
end
